<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 服务中心-工单-提交工单 -->
    <style>
    </style>
</head>
<body>
<div class="scroll-content2 my-service-center-tjgd" style="overflow:auto;background: #f1f1f1;">
    <div class="top-public">
        <span class="public-center">提交工单</span>        
        <img src="images/left_icon.png" alt="" class="public-left">
    </div>
    <a href="my_servicecenter_xzcp.html">
        <div class="xzcp">
            <span class="left">选择产品</span>
            <span class="right" id="headSonName">
                <!--展示类网站-->
            </span>
        </div>
    </a>
    <div class="write-detail">
        <p>问题描述</p>
        <textarea name="" id="question" cols="44" rows="6"></textarea>
    </div>
    <div class="write-bot">
        <ul>
            <li>
                <span>手机</span>
                <input type="text" placeholder="请输入手机号" value="" id="phonenumber">
            </li>
            <li>
                <span>邮箱</span>
                <input type="text" placeholder="请输入邮箱地址" value="" id="email">
            </li>
            <li onclick="time()">
                <span>接收短信时段</span>
                <input type="text" name="" id="itime" value="每日09:00-18:00" readonly="readonly" style="margin-right:0.2rem;">
            </li>
        </ul>
    </div>
    <div class="number-people">
        <ul>
            <li onclick="xz(this)">每日09:00-18:00</li>
            <li onclick="xz(this)">任何时间</li>
        </ul>
        <div class="close" onclick="closewin()">取消</div>
    </div>
    <div class="opacity-gray"></div>
    <div class="sub-btn" onclick="sub()">完成</div>
</div>
</body>
<script>
    $('.public-left').click(function(){
        window.history.go(-1);
    })
    $('.left-list li').click(function () {
        $('.left-list li').removeClass('active');
        $(this).addClass('active').siblings().removeClass('active');
        // $(".main").eq($(this).index()).show().siblings().hide();
    })
    function time(){
        $('.number-people').show();
        $('.opacity-gray').show();
    }
    function closewin(){
        $('.number-people').hide();
        $('.opacity-gray').hide();
    }
    function xz(obj){
        var text = $(obj).html();
        $('#itime').val(text);
        $('.number-people').hide();
        $('.opacity-gray').hide();
    }

    $(function() {
       var headSonName = sessionStorage.getItem('headSonName');
       $('#headSonName').html(headSonName);
       //验证是否登陆
       var user_id = sessionStorage.getItem('userId');
        if (user_id == null) {
            alert('请先登录！');
            window.location.href = 'login.html';
        }
    });

    function sub(){
        var user_id = sessionStorage.getItem('userId');
        var question = $('#question').val();
        var phonenumber = $('#phonenumber').val();
        var email = $('#email').val();
        var reg =/^[1][3,4,5,7,8][0-9]{9}$/; // 验证手机号
        var reg2 = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$"); // 验证邮箱
        var itime = $('#itime').val();
        var itime_num = 0;
        var headSonId = sessionStorage.getItem('headSonId');
        if(itime == '每日09:00-18:00'){
            itime_num = 1;
        }else{
            itime_num = 2;
        }
        if(question == ""){
            alert('问题描述不能为空');
            return false;
        }else if(phonenumber == ""){
            alert('请填写手机号');
            return false;
        }else if(email == ""){
            alert('请填写邮箱');
            return false;
        }else if(!reg.test(phonenumber)){
            alert('手机号输入有误,请重新输入');
            return false;
        }else if(!reg2.test(email)){
            alert('邮箱输入有误,请重新输入');
            return false;
        }else{
            $.ajax({
                url: url() + 'api/Invoice/workOrder',    //请求的url地址
                dataType: "JSON",   //返回格式为json
                async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                type: "POST",   //请求方式
                data:{
                    cid:headSonId,
                    user_id:user_id,
                    description:question,
                    mobile:phonenumber,
                    mailbox:email,
                    receiving:itime_num
                },
                success: function (data) {
                    console.log(data);
                    //请求成功时处理
                    if(data.status==1){
                        alert('提交成功,请耐心等待！');
                        window.location.href = 'my_servicecenter_gd.html';
                    } else {
                        alert(data.msg);
                    }
                }
            });

        }
    }
</script>
</html> 






